Fix for #163702, from Ivan Wong:
authorTor Lillqvist <tml@novell.com>
Sun, 23 Jan 2005 00:38:17 +0000 (00:38 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sun, 23 Jan 2005 00:38:17 +0000 (00:38 +0000)
2005-01-23  Tor Lillqvist  <tml@novell.com>

Fix for #163702, from Ivan Wong:

* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c: New flag _ignore_destroy_clipboard.

* gdk/win32/gdkevents-win32.c (gdk_event_translate): Handle
WM_DESTROYCLIPBOARD. Unless _ignore_destroy_clipboard, generate a
GDK_SELECTION_CLEAR event.

* gdk/win32/gdkselection-win32.c
(gdk_selection_owner_set_for_display): Set _ignore_destroy_clipboard
when emptying the clipboard ourselves.

(gdk_selection_send_notify_for_display): Remove the artifical
GDK_SELECTION_CLEAR event generation.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gdk/win32/gdkevents-win32.c
gdk/win32/gdkglobals-win32.c
gdk/win32/gdkprivate-win32.h
gdk/win32/gdkselection-win32.c

index feaed22ace5e1f77ed515dc5d79be2cfaf0d0fb4..4fb8bc9b8d9fa8bcce1e823c65acefd734e1b26c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        connected or not, so it's easier to just not try getting the
        volume name for them. See the bug report for discussion.
 
+       Fix for #163702, from Ivan Wong: 
+       
+       * gdk/win32/gdkprivate-win32.h 
+       * gdk/win32/gdkglobals-win32.c: New flag _ignore_destroy_clipboard.
+       
+       * gdk/win32/gdkevents-win32.c (gdk_event_translate): Handle
+       WM_DESTROYCLIPBOARD. Unless _ignore_destroy_clipboard, generate a
+       GDK_SELECTION_CLEAR event.
+
+       * gdk/win32/gdkselection-win32.c
+       (gdk_selection_owner_set_for_display): Set _ignore_destroy_clipboard
+       when emptying the clipboard ourselves.
+
+       (gdk_selection_send_notify_for_display): Remove the artifical
+       GDK_SELECTION_CLEAR event generation.
+
 2005-01-21  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkwidget.c (gtk_widget_get_accessible): More details
index feaed22ace5e1f77ed515dc5d79be2cfaf0d0fb4..4fb8bc9b8d9fa8bcce1e823c65acefd734e1b26c 100644 (file)
        connected or not, so it's easier to just not try getting the
        volume name for them. See the bug report for discussion.
 
+       Fix for #163702, from Ivan Wong: 
+       
+       * gdk/win32/gdkprivate-win32.h 
+       * gdk/win32/gdkglobals-win32.c: New flag _ignore_destroy_clipboard.
+       
+       * gdk/win32/gdkevents-win32.c (gdk_event_translate): Handle
+       WM_DESTROYCLIPBOARD. Unless _ignore_destroy_clipboard, generate a
+       GDK_SELECTION_CLEAR event.
+
+       * gdk/win32/gdkselection-win32.c
+       (gdk_selection_owner_set_for_display): Set _ignore_destroy_clipboard
+       when emptying the clipboard ourselves.
+
+       (gdk_selection_send_notify_for_display): Remove the artifical
+       GDK_SELECTION_CLEAR event generation.
+
 2005-01-21  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkwidget.c (gtk_widget_get_accessible): More details
index feaed22ace5e1f77ed515dc5d79be2cfaf0d0fb4..4fb8bc9b8d9fa8bcce1e823c65acefd734e1b26c 100644 (file)
        connected or not, so it's easier to just not try getting the
        volume name for them. See the bug report for discussion.
 
+       Fix for #163702, from Ivan Wong: 
+       
+       * gdk/win32/gdkprivate-win32.h 
+       * gdk/win32/gdkglobals-win32.c: New flag _ignore_destroy_clipboard.
+       
+       * gdk/win32/gdkevents-win32.c (gdk_event_translate): Handle
+       WM_DESTROYCLIPBOARD. Unless _ignore_destroy_clipboard, generate a
+       GDK_SELECTION_CLEAR event.
+
+       * gdk/win32/gdkselection-win32.c
+       (gdk_selection_owner_set_for_display): Set _ignore_destroy_clipboard
+       when emptying the clipboard ourselves.
+
+       (gdk_selection_send_notify_for_display): Remove the artifical
+       GDK_SELECTION_CLEAR event generation.
+
 2005-01-21  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkwidget.c (gtk_widget_get_accessible): More details
index 3e14cf904e2601170859793ec0a9c26d172e52a9..e8560cfadaec025622eb99f79364a274b6da0be7 100644 (file)
@@ -3353,7 +3353,19 @@ gdk_event_translate (GdkDisplay *display,
       handle_display_change ();
       break;
       
-
+    case WM_DESTROYCLIPBOARD:
+      if (!_ignore_destroy_clipboard)
+       {
+         event = gdk_event_new (GDK_SELECTION_CLEAR);
+         event->selection.window = window;
+         event->selection.selection = GDK_SELECTION_CLIPBOARD;
+         event->selection.time = _gdk_win32_get_next_tick (msg->time);
+          append_event (display, event);
+       }
+      else
+       return_val = TRUE;
+      break;
 #ifdef HAVE_WINTAB
       /* Handle WINTAB events here, as we know that gdkinput.c will
        * use the fixed WT_DEFBASE as lcMsgBase, and we thus can use the
index 4af1eb72d635123d00272f970f1140c20ef2295d..3778d7fdab55ed9856ec37cae7b25f52361df580 100644 (file)
@@ -66,3 +66,4 @@ gint            _gdk_input_ignore_wintab = FALSE;
 gint             _gdk_max_colors = 0;
 
 gboolean         _sizemove_in_progress = FALSE;
+gboolean         _ignore_destroy_clipboard = FALSE;
index f614aadbaf8e3feee081c9bdb620557de5b481f9..221e3429aecffa15a4006e0e3034bbeabbbcb3e6 100644 (file)
@@ -500,6 +500,9 @@ extern gint          _gdk_max_colors;
 /* TRUE while a user-initiated window move or resize operation is in progress */
 extern gboolean                 _sizemove_in_progress;
 
+/* TRUE when we are emptying the clipboard ourselves */
+extern gboolean                _ignore_destroy_clipboard;
+
 /* Initialization */
 void _gdk_windowing_window_init (void);
 void _gdk_root_window_size_init (void);
index 43e51cb9bc3efbac36a283c67b4c750cf9a689a4..aaf728376ee6a3217848762de03dd24e1e95634d 100644 (file)
@@ -238,16 +238,15 @@ gdk_selection_owner_set_for_display (GdkDisplay *display,
   if (!API_CALL (OpenClipboard, (hwnd)))
     return FALSE;
 
+  _ignore_destroy_clipboard = TRUE;
   if (!API_CALL (EmptyClipboard, ()))
     {
+      _ignore_destroy_clipboard = FALSE;
       API_CALL (CloseClipboard, ());
       return FALSE;
     }
-#if 0
-  /* No delayed rendering */
-  if (hwnd != NULL)
-    SetClipboardData (CF_TEXT, NULL);
-#endif
+  _ignore_destroy_clipboard = FALSE;
+
   if (!API_CALL (CloseClipboard, ()))
     return FALSE;
 
@@ -729,32 +728,6 @@ gdk_selection_send_notify_for_display (GdkDisplay *display,
             g_free (sel_name),
             g_free (tgt_name),
             g_free (prop_name)));
-
-  /* Send ourselves a selection clear message so that gtk thinks we
-   * don't have the selection, and will claim it anew when needed, and
-   * we thus get a chance to store data in the Windows clipboard.
-   * Otherwise, if a gtkeditable does a copy to CLIPBOARD several
-   * times only the first one actually gets copied to the Windows
-   * clipboard, as only the first one causes a call to
-   * gdk_property_change().
-   *
-   * Hmm, there is something fishy with this. Cut and paste inside the
-   * same app didn't work, the gtkeditable immediately forgot the
-   * clipboard contents in gtk_editable_selection_clear() as a result
-   * of this message. OTOH, when I changed gdk_selection_owner_get to
-   * return NULL for CLIPBOARD, it works. Sigh.
-   */
-
-  tmp_event.selection.type = GDK_SELECTION_CLEAR;
-  tmp_event.selection.window = gdk_window_lookup (requestor);
-  tmp_event.selection.send_event = FALSE;
-  tmp_event.selection.selection = selection;
-  tmp_event.selection.target = 0;
-  tmp_event.selection.property = 0;
-  tmp_event.selection.requestor = 0;
-  tmp_event.selection.time = time;
-
-  gdk_event_put (&tmp_event);
 }
 
 /* It's hard to say whether implementing this actually is of any use